package org.kd.ssh.dao;

import java.util.ArrayList;
import java.util.List;

import org.kd.ssh.domain.UserInfo;
import org.kd.ssh.util.MD5Utils;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDao extends HibernateDaoSupport {

	public UserInfo login(UserInfo userInfo) {
		List<UserInfo> userInfos = new ArrayList<UserInfo>();
		System.out.println(MD5Utils.md5(userInfo.getPassword()));
		userInfos = this.getHibernateTemplate().find(
				"from UserInfo where username=? and password = ? ",
				userInfo.getUsername(), MD5Utils.md5(userInfo.getPassword()));
		if (userInfos.size() > 0) {
			return userInfos.get(0);
		}
		return null;
	}
}
